package mytest;

class Mythread implements Runnable {//类实现接口，就必须要实现接口的抽象方法了
    @Override
    public void run() {

    }
}
interface test extends Runnable{//接口继承接口，接口本身就是抽象的，继续抽象

}
class MyThread extends Thread {//类继承抽象类，可以继续是抽象类
    @Override
    public void run() {//run-线程的入口方法
        while (true) {
            System.out.println("hello thread");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class Test1 {
    //public MyThread myThread = new MyThread();
    public static void main(String[] args) throws InterruptedException {//main-主线程的入口方法
        Thread myThread = new MyThread();
        myThread.start();//在系统中创建线程，线程执行run方法
        while (true) {
            System.out.println("hello main");
            Thread.sleep(1000);//Thread是java.lang包里面的
        }
    }
}
class test2 {
    /*public static void main(String[] args) {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("hello");
            }
        });
        Runnable runnable = thread;
        runnable.run();
    }*/
}

class test3 {
    public void methoud() {
        System.out.println(3);
    }
    /*public static void main(String[] args) {
        test3 test3 = new test5();
        test3.methoud();
        test3 test31 = new test3();
        test31.methoud();
    }*/
}
class test4 extends test3 {
    public  void methoud() {
        System.out.println(4);
    }


}
class test5 extends test4 {
    public void methoud() {
        System.out.println(5);
    }

    /*public static void main(String[] args) {
        test3 test3 = new test4();//重写要统一非静态的方法
        test3.methoud();
        test3 test31 = new test5();
        test31.methoud();
        test3 test32 = new test3();
        test3.methoud();
    }*/
    /*public static void main(String[] args) {
        test3 test3 = new test5();
        test3.methoud();
    }*/
}
class test6 {

}
class test7 {
    /*public static void main(String[] args) {
        test6 test6 = new test6();
    }*/
}

class ChildThread extends Thread{
    @Override
    public void run() {
        //run自实现内容
    }
}
class Test {
    public static void main(String[] args) {
        //1.用定义的Thread子类ChildThread 实例创建
        Thread thread1 = new ChildThread();
        thread1.start();

        //2.用扩展继承Thread的匿名子类 实例创建
        Thread thread2 = new Thread() {
            @Override
            public void run() {
                //run自实现内容
            }
        };
        thread2.start();
    }
}

class ChildRunnable implements Runnable{
    @Override
    public void run() {
        //run自实现内容
    }
}
class Test2 {
    public static void main(String[] args) {
        //1.用定义的Runnable实现类ChildRunnable 实例创建 Runnable的实现类实例
        Thread thread1 = new Thread(new ChildThread());
        thread1.start();

        //2.1用扩展实现Runnable接口的匿名子类 实例创建
        Thread thread2 = new Thread(new Runnable() {
            @Override
            public void run() {
                //run自实现内容
            }
        });

        //2.2Lambda表达式化简2.1
        Thread thread3 = new Thread(()->{
            //run自实现内容
        });
    }
}